// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: log_factory.cpp 216 2008-09-03 08:13:29Z heavyzheng $
//

#ifndef ZZHENG_LOGGING_SOURCE
#define ZZHENG_LOGGING_SOURCE
#endif // ZZHENG_LOGGING_SOURCE

#include <zzheng/logging/none/log_factory.hpp>
#include <zzheng/logging/log_level.hpp>
#include <zzheng/logging/destination.hpp>

#include <cassert>
#include <string>

namespace zzheng {
namespace logging {
namespace none_ {

    log_factory& log_factory::instance() {
        static log_factory instance;
        return instance;
    }

    log_factory::log_factory(): root_(), threshold_(default_level_number), dests_() {
        root_.reset(new logger(std::string(), threshold_));
    }

    log_factory::~log_factory() {
        // Do nothing.
    }

    void log_factory::set_threshold(const log_level& threshold) {
        threshold_ = threshold;
    }

    void log_factory::add_destination(const std::string& name, const destination& dest) {
        dests_[name] = dest;
    }

    bool log_factory::configure() {
        return true;
    }

    boost::weak_ptr<logger> log_factory::get_root() {
        assert(root_ != 0 && "Root logger should not be null.");
        return boost::weak_ptr<logger>(root_);
    }

} // namespace zzheng::logging::none_
} // namespace zzheng::logging
} // namespace zzheng


